// 目录表

const { STRING, INTEGER, DATE } = require("sequelize");

const sequelize = require("../sequelize");

const Catalogue = sequelize.define("Catalogue",{
    title:{
        type:STRING(50),
        allowNull:false,
        unique:true,
        comment:"目录名称"
    },
    createdate:{
        type:DATE,
        comment:"创建时间"
    },
    update:{
        type:DATE,
        comment:"修改时间"
    },
    creadator:{
        type:DATE,
        comment:"修改者"
    },
    updator:{
        type:DATE,
        comment:"修改者"
    },
})

Catalogue.associate = function(){
    Catalogue.hasMany(sequelize.Chapter,{
        foreignKey:"catalogueid",
        target:"id"
    })
}

module.exports = Catalogue